package com.jcf.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jcf.springboot.entity.sys.Menu;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jjj
 * @since 2021-03-19
 */
public interface MenuMapper extends BaseMapper<Menu> {

   List<String> selectMidByRid(String rid);

  @Select("\n" +
   "select * from menu where id in \n" +
   "(select mr.menu_id from sys_menu_role mr where mr.role_id in \n" +
   " (select r.id from sys_role r join sys_user_role ur on r.id = ur.role_id where ur.user_id = #{userId}))" +
   " ")
  List<Menu> getByUserId(String userId);

  @Select("delete from sys_menu_role where role_id = #{rid}")
  Boolean deletePermissByRids(String rid);

  boolean insertPermission(String rid, List<String> menuIds);

  void deleteMenu(Menu menu);
}
